<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0 time_moneylist" id="list" lay-title="计费管理">
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-body">
			  
			<div>
				<button class="layui-btn layuiadmin-btn-list" data-type="batchdel">删除</button>
				<button class="layui-btn layuiadmin-btn-list" data-type="add">添加</button>
			</div>
            <table class="layui-hide" id="list-table" lay-filter="list-table"></table>
			<div id="list-toolbar" style="display: none;">
			  <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
			            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
			</div>
			<script type="text/html" id="use_val">
				{{# layui.each(JSON.parse(d.use_val),function(i,item){ }}
 [{{item.hours}}小时--{{item.price}}元] 
{{# }) }}
			</script>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
   //表格数据渲染
  var formurl='hotel_time_money/time_moneyform',formarea=['600px', '600px'];
  layui.use(['table','form'], function () {
	  var table = layui.table
	  ,form = layui.form
	  ,$ = layui.$;
	  layui.admin.initlist(table,'device/hotel_rule_list',195,[[
		{type:'checkbox',fixed:'left'}
        ,{field:'hotel_id', title: 'ID', width:60}
        ,{field:'activity_name', title: '计费规则名称', width:150}
		,{field:'use_val', title: '计费规则详情', minWidth:200,templet:'#use_val'}
        ,{field:'create_time', title: '创建时间', width: 200}
		//,{field:'cost_status', title:'是否包时段', width:100, templet: '#list-tableF', unresize: true}
		,{title:'操作', toolbar: '#list-toolbar', width:150,fixed:'right'}
      ]])
	//监听表格操作事件
	table.on('tool(list-table)', function(obj){
	  var data = obj.data;
	  //删除
	  if(obj.event === 'del'){
		layer.confirm('确定删除'+data.activity_name+'?', function(index){
		  layui.admin.delF(table,'device/hotel_rule_delete',{hotel_id:data.hotel_id});
		});
	  } else if(obj.event === 'edit'){//编辑
		layui.admin.pupF('编辑计费',formarea,formurl,2,data)
	  }
	});
	//监听行双击事件
	/* table.on('rowDouble(list-table)', function(obj){
		//查看详情
		if($('.time_moneylist').length){
			layui.admin.pupF('计费详情',formarea,formurl,3,obj.data);
		}
	  
	}); */
	var active = {
	  //多行删除
	  batchdel:function(){
		  layui.admin.delsF(table,'device/hotel_rule_delete','hotel_id')
	  }
	  //添加
	  ,add: function(othis){
		layui.admin.pupF('添加计费',formarea,formurl,1,{})
	  }
	}; 
	//操作dom
	$('.layui-btn.layuiadmin-btn-list').on('click', function(){
	  var type = $(this).data('type');
	  active[type] ? active[type].call(this) : '';
	});
	
  });
</script>